import sys
import time
import logging
import threading

#print --> test import
try:
    import sub_pkg
    import demo_dbg
    print('import ...')
except ImportError:
    from . import sub_pkg
    from . import demo_dbg
    print('from . import ...')


# Initialize logger
logger = logging.getLogger(__name__)


class DemoMod:
    def __init__(self):
        """Initialize the Demo class."""
        logger.debug('Initializing Demo class.')
        self.dummy = []  # Example data structure


    def _thd(self):
        while True:
            logger.debug('Sleeping for 60 seconds...')
            time.sleep(60)


    def __call__(self):
        """Execute the Demo instance. Return None if an error occurs."""
        logger.debug('Calling Demo instance.')

        # Placeholder for error handling logic
        self.thd = threading.Thread(
            target=self._thd,
            daemon=True,
            name='demo'
        )
        self.thd.start()

        return self


def user_command(rob, cmd):
    """Process  commands."""
    if cmd in ('dummy', 'd'):  # dummy command
        print(rob.dummy)
    else:
        return False

    return True


if __name__ == '__main__':
    demo_dbg.main(DemoMod(), process_command=user_command)

